<template>
	<view>
		<view class="shop_index_bj  ">
			<image v-if="home_img" :src="home_img|getImg" style="width: 100%;" mode="widthFix"></image>
		</view>
		<view class="">
			<view class="row-wrap b_y pb2" style="background-color: #fff;">
				<view style="width: 148rpx;" v-for="(vo, index) in NavList" :key="index">
					<view style="padding-top:20rpx;text-align: center;" @click="on_index(vo.id)">
						<image class="q_y" :src="vo.img|getImg" style="width:80rpx;height:80rpx;border-radius: 96rpx;">
						</image>
						<view class="pt1">
							<text style="font-size: 26rpx;">{{vo.name}}</text>
						</view>
					</view>
				</view>
			</view>
		</view>

		<view class="p2 bg-white">
			<text class="w800 f32">超强推荐</text>
		</view>
		<view class="bg-white">
			<list1 :list="shop_list" :islog="islog" :log="log" :tabindex="tabindex"> </list1>
		</view>
		<view class="" style="height: 200rpx;">

		</view>
		<tabbar></tabbar>

	</view>
</template>

<script>
	import list1 from "./list1.vue";


	export default {
		components: {
			list1,

		},
		data() {
			return {
				title: 'Hello',
				set: {},
				NavList: [],
				statistics: {},
				shop_list: [],
				tabindex: 0,
				islog: true,
				log: '加载中',
				url: '',
				search_key: '',
				home_img:''

			}
		},

		onLoad() {
			var pages = getCurrentPages()
			let currentRoute = pages[pages.length - 1].route;
			this.api_path = currentRoute.match(/pages\/(\S*)\//)[1];
			this.page = 1;
			var that = this;
			this.init();

		},
		onShareAppMessage(res) {
			return {
				title: this.set.shop_name,
				path: '/pages/banmichaoqiangbizhi/index',
				imageUrl: '',
			}
		},

		onShareTimeline(res) {
			return {
				title: this.set.shop_name,
				path: '/pages/banmichaoqiangbizhi/index',
				imageUrl: '',
			}
		},
		methods: {
			on_search() {
				uni.navigateTo({
					url: '/pages/' + this.api_path + '/shop_search?search_key=' + this.search_key
				})
			},
			on_index(id) {
				uni.navigateTo({
					url: '/pages/' + this.api_path + '/nav_list?id=' + id
				})
			},
			on_tab(index) {
				this.shop_list = [];
				this.islog = true;
				this.page = 1; 
				this.log = '加载中';
				this.tabindex = index;
				this.shop_init(this.tabindex);
			},
			init() { 
				let requestParams = {};

				this.Http.post('/plugin.php/banmichaoqiangbizhi/api/index/index', requestParams).then(ret => {
					if (ret.status == 200) {
						var set_find = this.get_plugin_set
					 
						if (set_find.website_name) {
							uni.setNavigationBarTitle({
								title: set_find.website_name
							})
						}
						this.home_img = set_find.home_img;
						this.NavList = ret.data.NavList;
						this.shop_init();
					}
				})
			},
			shop_init() {
				var that = this;
				let requestParams = {
					page: this.page,
					tabindex: this.tabindex
				};
				this.Http.post('/plugin.php/banmichaoqiangbizhi/api/index/shop_list', requestParams).then(ret => {

					if (ret.status == 200) {
						if (that.page == 1) {
							this.shop_list = ret.data.shop_list.data;
						} else {
							if (ret.data.shop_list.data.length > 0) {
								for (var i = 0; i < ret.data.shop_list.data.length; i++) {
									that.shop_list.push(ret.data.shop_list.data[i]);
								}
							}
							if (ret.data.shop_list.data < 10) {
								this.log = "没有数据了"
							}
						}
						setTimeout(() => {
							that.isinit = false;
							that.islog = false;
						}, 100)


					}



				})
			},

		},
		onReachBottom() {
			this.jiazai = "加载中...";
			this.page = this.page += 1;
			this.shop_init();
		},
	}
</script>

<style>
	.row-wrap {
		display: flex;
		flex-direction: row;
		flex-wrap: wrap;
	}

	.row-wrap-img {
		width: 80rpx;
		height: 80rpx;
		border-radius: 96rpx;
	}


	.shop_index_bj {
		height: 450rpx;
		width: 100%;
		background-repeat: no-repeat;
		background-size: 100% 100%;
	}




	.shop_index_bj {
		height: 450rpx;
		width: 100%;
		background-repeat: no-repeat;
		background-size: 100% 100%;
	}
</style>